package com.qingcloud.base.remote.executor;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public class ExecutorParam implements Serializable {

    @Data
    @ApiModel("作业参数")
    public static class JobParam {

        @ApiModelProperty(value = "作业ID", example = "1")
        private Integer jobId;

        @ApiModelProperty(value = "作业运行环境 pro-正式环境 dev-开发环境", example = "dev")
        private String env = "pro";

        @ApiModelProperty("实例参数列表")
        List<InstanceParam> instanceParams;

    }

    @Data
    @ApiModel("实例参数")
    public static class InstanceParam {

        @ApiModelProperty(value = "作业ID", example = "1")
        private Integer jobId;

        @ApiModelProperty(value = "实例ID", example = "1")
        private Integer instanceId;

        @ApiModelProperty(value = "配置文件下载地址", example = "1")
        private String configUrl;

        @ApiModelProperty(value = "作业运行环境 pro-正式环境 dev-开发环境", example = "dev")
        private String env = "dev";

        @ApiModelProperty(value = "PowerJob 任务编号", example = "0")
        private Long taskId = 0L;

        @ApiModelProperty(value = "cron表达式", example = "0 1 * * * *")
        private String cron;

    }

    @Data
    @ApiModel("组件参数")
    public static class ComponentConfigParam {
        @ApiModelProperty(value = "组件编号", example = "1")
        private Integer componentId;
        @ApiModelProperty(value = "组件存储路径", example = "1")
        private String objectPath;
        @ApiModelProperty(value = "组件英文名称", example = "1")
        private String componentNameEn;
        @ApiModelProperty(value = "组件类型", example = "1")
        private Integer componentType;
        @ApiModelProperty(value = "组件运行方式", example = "1:独立执行;2: 嵌入式")
        private Integer runMode;
        @ApiModelProperty(value = "配置参数", example = "1")
        private Map<String,String> paramMap;
    }

    /**
     * 批量控制组件实例参数对象
     */
    @Getter
    @Setter
    @ToString
    @ApiModel("批量控制组件实例参数")
    public static class IdListParam {

        @ApiModelProperty(value = "实例ID数组", example = "[1,2]")
        private List<Integer> ids;

        @ApiModelProperty(value = "实例运行环境, pro-正式 dev-开发")
        private String env = "pro";

    }


    /**
     * 修改cron表达式对象
     */
    @Getter
    @Setter
    @ToString
    @ApiModel("修改cron表达式参数对象")
    public static class ModifyCron {

        @ApiModelProperty(value = "实例ID", example = "1")
        private Integer instanceId;

        @ApiModelProperty(value = "cron表达式", example = "0 1 * * * *")
        private String cron;

    }

    /**
     * 修改cron表达式参数对象
     */
    @Getter
    @Setter
    @ToString
    @ApiModel("批量修改cron表达式参数")
    public static class ModifyCronParam {

        @ApiModelProperty(value = "实例ID", example = "网络错误")
        private List<ModifyCron> cronList;

        @ApiModelProperty(value = "实例运行环境, pro-正式 dev-开发")
        private String env = "pro";
    }
}
